# twisted imports
from twisted.conch import telnet
from twisted.internet import protocol,reactor
from twisted.python import log, failure


from Gamestates import *
games = []

"""Naive usage of twisted for my telnet"""

class Game(telnet.Telnet):
   def connectionMade(self):
      """When creating the connection, add self to a global list of game sessions"""
      telnet.Telnet.connectionMade(self)
      games.append(self)
      """We enter in the MOTD state"""
      self.gamestate = MOTD(self)
      self.gamestate.go()

   def write(self,data):
      """ """
      self.transport.write(data)
   def dataReceived(self, data):
      """When data is received dispatch it to the current game state"""
      self.gamestate.input(data)

class GameFactory(protocol.Factory):
    protocol = Game


